package com.itheima.app.controller;

import com.itheima.app.manager.UserLikeManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserLikeController {

    @Autowired
    private UserLikeManager userLikeManager;

    // 右滑喜欢
    @GetMapping({"/tanhua/{likeUserId}/love"})
    public void cardLove(@PathVariable Long likeUserId) {
        // 调用manager
        userLikeManager.cardLove(likeUserId);

    }

    // 左滑不喜欢
    @GetMapping("/tanhua/{likeUserId}/unlove")
    public void cardUnlove(@PathVariable Long likeUserId) {
        // 调用manager
        userLikeManager.cardUnlove(likeUserId);
    }

    // 我的统计
    @GetMapping("/users/counts")
    public ResponseEntity myCounts() {
        // 调用manager
        return userLikeManager.myCounts();
    }

    // 我的详情
    @GetMapping("/users/friends/{type}")
    public ResponseEntity myDetail(
            @PathVariable Integer type,
            @RequestParam(value = "page", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize) {
        // 调用manager
        return userLikeManager.myDetail(type, pageNum, pageSize);
    }

    // 粉丝喜欢
    @PostMapping("/users/fans/{likeUserId}")
    public void fanLike(@PathVariable Long likeUserId) {
        // 调用manager
        userLikeManager.cardLove(likeUserId);
    }

    // 取消喜欢
    @DeleteMapping("/users/like/{likeUserId}")
    public void unlove(@PathVariable Long likeUserId) {
        // 调用manager
        userLikeManager.cardUnlove(likeUserId);
    }
}
